﻿var showHideColumn = function( gridID,colIndex) {
		
		  //为了 显示 隐藏列用
	      var columnModels = $("#" + gridID).jqGrid('getGridParam','colModel');
	      var columnNames = $("#" + gridID).jqGrid('getGridParam','colNames');
	      
	      //init column selectlist 
	      var option="";
	      
	      var colCount=0;
	      $.each(columnModels,function(key,value){	    	  
	    	 
	    	  if ( colCount >= colIndex)
	    	  {
			 	  //循环得到每一个列名	
		    	  //if (value.label != null)
		    	  option += "<option value='"+value.name+ "'>" + columnNames[colCount] + "</option>";
	    	  }
	    	  colCount ++;
		   });
	      
	      $("#t_" + gridID).
	      append(
	    		 "<select style ='width:300' name='columesShowHide' id='columesShowHide' multiple>"+
	    		 option +
	    		
				"</select>"	
	    		 /*+				"<input id='columesShowHide_Result' type = 'hidden'></input>"*/				
	      );
	      
	      $("#columesShowHide").multiselect({checkAllText:'全选',uncheckAllText:'不选',selectedList: 10,noneSelectedText:""});
	    	
		  		      
	  	//column show hide
			$("#columesShowHide").multiselect({
				close: function(event, ui){					
				     //grid 需要 显示的列
					var showCols = $("#columesShowHide").val();
					colCount =0;
					
				   $.each(columnModels,function(key,value){
					   
					   if ( colCount >= colIndex)
				    	  {
							   
						 	  //循环得到每一个列名		 
							  //alert(value.name);
						 	   var colName = value.name;				 	    
						 	   if(showCols ==null || showCols.indexOf(colName) == -1){
						 	   
						 		   $("#"+ gridID).jqGrid('hideCol',colName);
						 	   }
						 	   else	if(showCols !=null || showCols.indexOf(colName)!=-1){
								   //System.out.println("包含");
							  		$("#" + gridID).jqGrid('showCol',colName);
								  }
				 	   
				    	  }
					   colCount ++;
				   });
				     
				   }
			});
};